{extend name="public/base" /}
{block name="title"}评论管理{/block}
{block name="css"}
<link rel="stylesheet" href="__PUBLIC__/static/inspinia/css/plugins/datapicker/bootstrap-datetimepicker.min.css">
{/block}
{block name="main"}


<div class="wrapper wrapper-content">
    <div class="row">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>评论列表 </h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-wrench"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="{:url(request()->controller().'/index')}">文章管理</a></li>
                    </ul>
                    <a class="close-link">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content" style="padding:10px">
                <div>
                    <div class="feed-activity-list">
                        {foreach name="list" item="vo"}
                        <div class="feed-element">
                            <div class="media-body ">
                                {empty name="$vo.pid"}
                                <small class="pull-right text-navy">{$vo.create_time|friendly_date}</small>
                                <strong>{$vo.author}</strong> 评论了文章<strong>
                                <a class="J_addMenuTab" href="{:url(request()->controller().'/viewArticle',['id'=>$vo['article_id']])}">
                                    {$vo.article.title}</a></strong>
                                <br>
                                <small class="text-muted">来自  {$vo.ip|ip_to_address=###, 'province,city'}</small>
                                {else /}
                                <small class="pull-right text-navy">{$vo.create_time|friendly_date}</small>
                                <strong>{$vo.author}</strong> 回复了评论<strong>
                                <a class="J_addMenuTab" href="{:url(request()->controller().'/viewArticle',['id'=>$vo['article_id']])}">
                                    {$vo.reply.content}</a></strong>
                                <br>
                                <small class="text-muted" >来自  {$vo.ip|ip_to_address=###, 'province,city'}</small>
                                {/empty}
                                <div class="well">
                                    {$vo.content}
                                </div>

                                <div class="actions">
                                    <a href="{:url(request()->controller().'/viewArticle',['id'=>$vo['article_id']])}">
                                        <button class="btn btn-xs btn-info" data-toggle="tooltip" data-placement="top" title="查看">
                                            <i class="fa fa-eye"></i> 查看</button>
                                    </a>
                                    {if $vo.status == 0}
                                    <button class="btn btn-xs btn-primary ajax-btn-warning"
                                            data-action="{:url(request()->controller().'/auditComment',['id'=>$vo['id']])}"
                                            data-title="提示" data-text="审核通过后将自动发布，确认要审核通过吗？"><i class="fa fa-check"></i> 审核</button>
                                    {elseif $vo.status >= 3/}
                                    <button class="btn btn-xs btn-primary ajax-btn-warning"
                                            data-action="{:url(request()->controller().'/auditComment',['id'=>$vo['id']])}"
                                            disabled><i class="fa fa-check"></i> 已发布</button>
                                    {/if}

                                    <button type="button" class="btn btn-xs btn-danger ajax-btn"
                                            data-action="{:url('Article/deleteComment',['id'=>$vo['id']])}"
                                            data-toggle="tooltip" data-placement="top" title="删除"><i class="icon-remove"></i> 删除
                                    </button>

                                    <button type="button" class="btn btn-xs btn-white" data-toggle="modal" data-id="{$vo.id}" data-aid="{$vo.article_id}" onclick="reply(this)">
                                        <i class="fa fa-comment"></i>
                                        回复
                                    </button>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>

                    <div>
                        {$pages|raw}
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>



<div class="modal fade" id="replyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    回复评论
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal ajax-form" action="{:url(request()->controller().'/postComment')}" method="post">
                    <input type="hidden" name="pid" value="0">
                    <input type="hidden" name="article_id" value="0">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">回复内容:</label>
                        <div class="col-lg-10">
                            <textarea name="content" style="width: 430px; height: 100px"></textarea> <span class="help-block m-b-none"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button class="btn btn-sm btn-white" type="submit">回复</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<!--日期选择器-->
<script src="__PUBLIC__/static/inspinia/js/plugins/datapicker/bootstrap-datetimepicker.min.js"></script>
<script src="__PUBLIC__/static/inspinia/js/plugins/datapicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>

<script>
    function reply(obj) {
        var id = $(obj).data('id');
        var aid = $(obj).data('aid');
        $("input[name = 'pid']").val(id);
        $("input[name = 'content']").val('');
        $("input[name = 'article_id']").val(aid);

        $("#replyModal").modal('show');
    }
  
</script>

{/block}